<?php

require_once dirname(__FILE__) . '/../lib/questionGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/questionGeneratorHelper.class.php';

/**
 * question actions.
 *
 * @package    iEasy
 * @subpackage question
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class questionActions extends autoQuestionActions
{
    public function executeDeleteUserQuestion(sfWebRequest $request)
    {
        $questionId = $request->getParameter("questionId");
        $question = Doctrine_Core::getTable("question")->find($questionId);
        if ($question != null) {
            $available = $request->getParameter("available");
            $question->setIsAvailable($available);
            $question->save();
            if ($request->isXmlHttpRequest()) {
                return $this->renderComponent('question', 'questionList', array('question_channel_id' => $question->getQuestionChannelId()));
            }
        }

    }

    public function executeDoTopQuestion(sfWebRequest $request)
    {
        $questionId = $request->getParameter("questionId");
        $question = Doctrine_Core::getTable("question")->find($questionId);
        if ($question != null) {
            $top = $request->getParameter("top");
            $question->setIsOnTop($top);
            $question->save();
            if ($request->isXmlHttpRequest()) {
                return $this->renderComponent('question', 'questionList', array('question_channel_id' => $question->getQuestionChannelId()));
            }
        }
    }
}
